#include "ft32f0xx.h"
#include "info.h"
#include "stdio.h"
#include "bsp.h"

unsigned char buf[4] = {1,2,3,4};
GBool tmp = GFalse;
void delay_1ms(void)
{
    uint32_t temp;
    SysTick->LOAD = 48000UL - 1;
    SysTick->VAL = 0X00; //清空计数器
    SysTick->CTRL |= SysTick_CLKSource_HCLK;
    SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
    do
    {
        temp = SysTick->CTRL;                         //读取当前倒计数值
    } while ((temp & 0x01) && (!(temp & (1 << 16)))); //等待时间到达
    SysTick->CTRL = 0x00;                             //关闭计数器
    SysTick->VAL = 0X00;                              //清空计数器
}

void delay_ms(uint16_t nms)
{
    while(nms--)
    {
        delay_1ms();
    }
}
/*主函数执行一个基于串口的简单交互工具用来进入调试模式*/
int main()
{
    BSP_Init_Result bsp_ret;
    bsp_init(&bsp_ret);
    //printf("BoatXu App.\n");
    //timeout_scanf("%ul", &code);
    while (1)
		{
			tmp = !tmp;
			bsp_led_set(tmp);
			delay_ms(1000);
		}
}
